{%extends 'base_detail_list.html'%}

{%block topfiles%}
{%load static%}
<script src='{%static "js/jquery-1.12.4.min.js"%}'></script>
<script>
	$(function(){
		function change(){
			if ('{{sort_method}}' == 'price'){
				$('#sort_byPrice').addClass('active')
			}
			else if('{{sort_method}}' == 'id'){
				$('#sort_byId').addClass('active')
			}
			else if('{{sort_method}}' == 'sales')
			{
				$('#sort_bySales').addClass('active')
			}
		}
		change()

	})
</script>
{%endblock topfiles%}

{%block body%}
<div class="navbar_con">
    <div class="navbar clearfix">
        <div class="subnav_con fl">
            <h1>全部商品分类</h1>	
            <span></span>			
            <ul class="subnav">
				{%for t in types%}
				<li><a href="/list/{{t.id}}/1" class="{{t.logo}}">{{t.name}}</a></li>
				{%endfor%}
            </ul>
        </div>
        <ul class="navlist fl">
            <li><a href="/index">首页</a></li>
            <li class="interval">|</li>
            <li><a href="">手机生鲜</a></li>
            <li class="interval">|</li>
            <li><a href="">抽奖</a></li>
        </ul>
    </div>
</div>
	<div class="breadcrumb">
		<a href="#">全部分类</a>
		<span>></span>
		<a href="/list/{{tp.id}}/1">{{tp.name}}</a>
	</div>
{%block main_content%}
	<div class="main_wrap clearfix">
		<div class="l_wrap fl clearfix">
			<div class="new_goods">
				<h3>新品推荐</h3>
				<ul>
					{%for good in new_goods%}
					<li>
						<a href="/detail/{{good.id}}"><img src="{{good.image.url}}"></a>
						<h4><a href="/detail/{{good.id}}">{{good.name}}</a></h4>
						<div class="prize">￥{{good.price}}</div>
					</li>
					{%endfor%}

				</ul>
			</div>
		</div>

		<div class="r_wrap fr clearfix">
			<div class="sort_bar">
				<a href="/list/{{tp.id}}/{{goods.number}}?sort=id"  id='sort_byId'>默认</a>
				<a href="/list/{{tp.id}}/{{goods.number}}?sort=price" id='sort_byPrice'>价格</a>
				<a href="/list/{{tp.id}}/{{goods.number}}?sort=sales" id='sort_bySales'>人气</a>
			</div>

			<ul class="goods_type_list clearfix">
				{%for good in goods%}
				<li>
					<a href="/detail/{{good.id}}"><img src="{{good.image.url}}"></a>
					<h4><a href="/detail/{{good.id}}">{{good.name}}</a></h4>
					<div class="operate">
						<span class="prize">￥{{good.price}}</span>
						<span class="unit">{{good.price}}/{{good.unite}}</span>
						<a href="#" class="add_goods" title="加入购物车"></a>
					</div>
				</li>
				{%endfor%}
			</ul>

			<div class="pagenation">
				{% if goods.has_previous %}
				<a href="/list/{{goods.object_list.0.type.id}}/{{goods.previous_page_number}}?sort={{sort_method}}">上一页</a>
				{%else%}
				<a>上一页</a>
				{%endif%}
				{%for i in goods.paginator.page_range%}
				{%if i == goods.number%}
				<a  class="active">{{i}}</a>
				{%else%}
				<a href="/list/{{goods.object_list.0.type.id}}/{{i}}?sort={{sort_method}}">{{i}}</a>
				{%endif%}
				{%endfor%}
				{% if goods.has_next %}
				<a href="/list/{{goods.object_list.0.type.id}}/{{goods.next_page_number}}?sort={{sort_method}}">下一页></a>
				{%else%}
				<a >下一页</a>
				{%endif%}
			</div>
		</div>
	</div>
{%endblock main_content%}


{%endblock body%}
